package pixelwaks.core.impl;

import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import common.util.FileHandler;


public class Player {

	private Point playerPos;
	private double radian;
	private int chargeStrength;
	private double health;
	private String name;
	private BufferedImage body;
	private BufferedImage barrel;
	private List<Weapon> weapons;
	private int currentWeapon;
	public static final int BARREL_OFFSET = 5;

	public Player(Point p) {
		
		playerPos = p;
		radian = 0;
		chargeStrength = 0;
		health = 100;
		weapons = new ArrayList<Weapon>();
		
//		//weapon should be in xml?
//		BufferedImage img1 = FileHandler.getImage("weapon_1_3d.png");
//		BufferedImage img2 = FileHandler.getImage("weapon_2_3d.png");
//		BufferedImage img3 = FileHandler.getImage("weapon_3_3d.png");
//		weapons.add (new Weapon(img1, 3, 3, -1));
//		weapons.add (new Weapon(img2, 5, 5, 10));
//		weapons.add (new Weapon(img3, 10, 10, 5));
		
		currentWeapon = 0;
		try {
			body = FileHandler.getImage(FileHandler.PLAYER, "body_3d.png");
			barrel = FileHandler.getImage(FileHandler.PLAYER, "barrel_3d.png");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
		
	public double getBarrelAngle() {
		
		return (Math.PI / 2) - radian;
	}

	public void setChargeStrength(int i) {
		
		chargeStrength = i; 
	}
	
	public void setWeapon(int i) {
		
		currentWeapon = i;
	}
	
	public int getChargeStrength() {

		return chargeStrength;
	}

	public Point getPosition() {

		return playerPos;
	}

	public void setRadians(double radian) {
		
		this.radian = radian;
	}
	
	public double getRadians() {

		return radian;
	}

//	public boolean isAlive() {
//
//		return health > 0;
//	}

	public String getName() {

		return name;
	}

	public void setName(String name) {

		this.name = name;
	}
	
	public void setStatus(double d) {
		
		health = d;
	}

	public double getStatus() {

		return health;
	}

	public BufferedImage getBody() {

		return body;
	}

	public BufferedImage getBarrel() {

		return barrel;
	}

	public double getDegrees() {

		return 90.0 - (getRadians() * (180.0 / Math.PI));
	}

	public void setWeapons(List<Weapon> weapons) {
		this.weapons = weapons;
	}
	public List<Weapon> getWeapons() {
		return weapons;
	}
	
	public Weapon getCurrentWeapon() {
		return weapons.get(currentWeapon);
	}
}
